package com.atom.plugin.core.concurrent

import java.util.concurrent.*

object Schedulers {
    private val cpuCount = Runtime.getRuntime().availableProcessors()
    private val IO: ExecutorService = ThreadPoolExecutor(
        0, cpuCount * 3,
        30L, TimeUnit.SECONDS,
        LinkedBlockingQueue()
    )
    private val SINGLE: ExecutorService = Executors.newSingleThreadExecutor()

    private val COMPUTATION = Executors.newWorkStealingPool(cpuCount)

    fun single(): ExecutorService {
        return SINGLE
    }

    fun io(): ExecutorService {
        return IO
    }

    fun computation(): ExecutorService {
        return COMPUTATION
    }

    fun forkJoinPool(): ForkJoinPool {
        return COMPUTATION as ForkJoinPool
    }
}